workdir=/nvme_data/attach-images

domains=(
#compute2-192.168.0.199
#rl-ceph1-192.168.0.139
#rl-ceph2-192.168.0.201
#rl-ceph3-192.168.0.222
node-192.168.0.133
node-192.168.0.135
node-192.168.0.136
node-192.168.0.137
node-192.168.0.138
)

format=raw
attach_size=50G
attach_disks=(
vdb
vdc
vdd
)

add_dev() {
        local domain=$1
        local devname=$2
        local image=$workdir/$domain-$devname.img
        [ -f $image ] || qemu-img create -f $format $image $name $attach_size
if virsh domblklist $domain  | grep $image ||
virsh domblklist $domain  | grep $devname; then
        echo "$image exists or already mount $devname"
        return
else
virsh attach-disk $domain $image $devname --subdriver $format --targetbus virtio  --cache writeback
fi
}


for domain in ${domains[@]}; do
        for _devname in ${attach_disks[@]}; do
        add_dev $domain $_devname
        done
done